import request from '@/utils/request'

export function loginByUsername(username, password, captcha, captchauuid) {
  const data = {
    username,
    password,
    captcha,
    captchauuid,
    'client_id': 'test_client',
    'client_secret': '123456',
    'grant_type': 'password',
    'scope': 'read'
  }
  // 登录
  return request({
    url: '/authorization-server/oauth/token',
    method: 'get',
    params: data,
    headers: { 'Authorization': '' }
  })
}

export function captcha() {
  return request({
    url: '/captcha.jpg?t=' + new Date().getTime(),
    method: 'get'
    // 如果data 则是json，如果改成params则是表单提交
  })
}

// 登出
export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

export function getUserInfo() {
  return request({
    url: '/platform-web/info',
    method: 'get'
  })
}

